package cn.zzuli.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@Slf4j
@RequestMapping("/provider")
public class paymentController {

    @Value("${server.port}")
    private String serverPort;


    @GetMapping(value = "/payment/zk")
    public String paymentZk(){
        return serverPort+"\t"+ UUID.randomUUID().toString();
    }




//    @Resource
//    private PaymentService paymentService;
//
//    @Resource
//    private DiscoveryClient discoveryClient;

//    @PostMapping("/payment")
//    public CommonResult create(@RequestBody Payment payment){
//        CommonResult commonResult = paymentService.create(payment);
//        System.out.println("-$$$$$$$$$#########*****************: "+serverPort);
//        return commonResult;
//    }
//
//    @GetMapping("/payment/{id}")
//    public CommonResult getPayMentById(@PathVariable("id") Long id){
//
//        CommonResult<Payment> payMentById = paymentService.getPayMentById(id);
//        System.out.println("-$$$$$$$$$#########*****************: "+serverPort);
//        return payMentById;
//    }
//
//
//    @GetMapping(value = "/payment/discovery")
//    public Object discover(){
//        List<String> services = discoveryClient.getServices();
//        services.forEach(service->{
//            log.info("***************service: "+service);
//        });
//        List<ServiceInstance> instances = discoveryClient.getInstances("PROVIDER-PAYMENT");
//        instances.forEach(instance->{
//            log.info(instance.getServiceId()+ " ************* "+instance.getHost()+ " ************* "+instance.getPort()+ " ************* "+instance.getUri());
//        });
//        return this.discoveryClient;
//    }
}
